package com.hansen.library.utils;

/**
 * 快速点击判断
 * <p>
 * Created by han on 2019/7/2 0002.
 */

public class FastClickUtils {
    private static final int FAST_CLICK_DELAY_TIME = 500;  // 快速点击间隔
    private static long lastClickTime = 0L;
    private static long lastNoRecordClickTime;

    public static boolean isFastClick() {
        boolean flag = true;

        long currentClickTime = System.currentTimeMillis();

        if ((currentClickTime - lastClickTime) >= FAST_CLICK_DELAY_TIME) {
            flag = false;
        }

        lastClickTime = currentClickTime;
        lastNoRecordClickTime = currentClickTime;

        return flag;
    }

    /**
     * 用于判断录制按钮和其他按钮同时按下
     *
     * @return
     */
    public static boolean isRecordWithOtherClick() {
        boolean flag = true;

        long currentClickTime = System.currentTimeMillis();

        if ((currentClickTime - lastNoRecordClickTime) >= FAST_CLICK_DELAY_TIME) {
            flag = false;
        }

        lastClickTime = currentClickTime;

        return false;
    }
}
